<template>
    <div style="width:40%;margin-left: 50px;margin-top:5%">
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="150px" class="demo-ruleForm">
            <el-form-item label="委托合同编号：" prop="htbh">
                <el-input type="text" v-model="ruleForm.htbh">
                </el-input>
            </el-form-item>
            <el-form-item label="业务类型：" prop="ywlx">
                <el-select v-model="ruleForm.ywlx" clearable placeholder="业务类型" style="width:100%">
                    <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="对接人：" prop="djr">
                <el-input type="text" v-model="ruleForm.djr">
                </el-input>
            </el-form-item>
            <el-form-item label="评估师：" prop="pgs">
                <el-select v-model="ruleForm.pgs" clearable placeholder="选择评估师" style="width:100%">
                    <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label=" 开始时间：" prop="startTime">
                <el-date-picker v-model="ruleForm.startTime" type="datetime" placeholder="选择日期时间"
                    default-time="12:00:00">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="结束时间：" prop="endTime">
                <el-date-picker v-model="ruleForm.endTime" type="datetime" placeholder="选择日期时间" default-time="12:00:00">
                </el-date-picker>
                <span>
                    <el-tag size="mini">从合同日期开始，最长不超过60天</el-tag>
                </span>
            </el-form-item>
            <el-form-item label="委托方类型：" prop="wtflx">
                <el-select v-model="ruleForm.wtflx" clearable placeholder="选择委托方类型" style="width:100%">
                    <el-option label="个人" value="个人"></el-option>
                        <el-option label="企业机构" value="企业机构"></el-option>
                        <el-option label="司法机构" value="司法机构"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm()" style="margin-left:30%" width="10px">确定
                </el-button>
                <!-- <el-button class="pull-right">取消</el-button> -->
            </el-form-item>
        </el-form>
    </div>
</template>
<script>
import { create } from '@/api/evaluation/newBusiness';
import { findByName } from '@/api/systemManage/dataDictionary';
export default {
    name: 'newBusiness',
    data () {
        return {
            ruleForm: {
                qyid: 1,
            },
            options1: [],
            options2: [{
                label: '评估师一',
                value: '评估师一'
            }, {
                label: '评估师二',
                value: '评估师二'
            }
            ],
            rules: {
                ywlx: [
                    { required: true, message: '请选择业务类型', trigger: 'change' }
                ],
                // num: [
                //     { required: true, message: '请输入合同编号', trigger: 'change' }
                // ],
                djr: [
                    { required: true, message: '请输入对接人', trigger: 'change' }
                ],
                pgs: [
                    { required: true, message: '请选择评估师', trigger: 'change' }
                ],
                startTime: [
                    { required: true, message: '请设置时效', trigger: 'change' }
                ],
                wtflx: [
                    { required: true, message: '请选择委托方类型', trigger: 'change' }
                ],
            },


        };
    },
    methods: {
        dataDictionaryList () {
            findByName('input=' + '业务类型').then((res) => {
                for (var i = 0; i < res.data.length; i++) {
                    if(res.data[i].dictName=='业务类型')
                    this.options1.push({
                        label: res.data[i].dictValue,
                        value: res.data[i].dictValue
                    })
                }
            })
            findByName('input=' + '评估师').then((res) => {
                for (var i = 0; i < res.data.length; i++) {
                    if(res.data[i].dictName=='评估师')
                    this.options2.push({
                        label: res.data[i].dictValue,
                        value: res.data[i].dictValue
                    })
                }
            })
            
        },
        submitForm () {
            this.$refs.ruleForm.validate((valid) => {
                if (valid) {
                    create(this.ruleForm).then((res) => {
                        this.$message.success('创建成功')
                        this.$emit('dialogClose')
                        location.reload()
                        // this.$router.replace(path)
                    })
                }
                else {
                    return
                }
            });
        },

        // 重置
        // resetForm (formName) {
        //     this.$refs[formName].resetFields();
        // },
    },
    mounted () {
        this.dataDictionaryList()
    }


}
</script>
<style lang="less" scoped>
.el-button--medium {
    padding: 15px 45px;
    font-size: 14px;

}

// :deep .el-input.is-disabled .el-input__inner {
//     background-color: #fff;
//     border-color: #e4e7ed;
//     color: #606266;
//     cursor: not-allowed;
// }

:deep .el-form-item__label {
    position: relative;
    display: inline-block;
    text-align-last: justify;
}

.demo-ruleForm :deep .el-form-item--medium .el-form-item__label::before {
    display: none;
}
</style>